home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / hard / hack / i2clib40.lha / i2clib40 / Developer / GNU_include / libraries / i2c.h
C/C++ Source or Header  |  1998-08-30  |  3KB  |  84 lines

  1. #ifndef LIBRARIES_I2C_H
  2. #define LIBRARIES_I2C_H
  3.  
  4. /*
  5. **    $VER: i2c.h 40.0 (11.08.98)
  6. **
  7. **    Useful definitions for i2c.library (return codes, libbase etc.)
  8. **
  9. */
  10.  
  11. #ifndef EXEC_TYPES_H
  12. #include <exec/types.h>
  13. #endif
  14.  
  15. #ifndef EXEC_LIBRARIES_H
  16. #include <exec/libraries.h>
  17. #endif
  18.  
  19. /* If you call SetI2CDelay only to read the delay, not change it: */
  20. #define I2CDELAY_READONLY 0xffffffff    /* V39+ ! */
  21.  
  22. /* Type of delay to pass to AllocI2C (obsolete in V39+, see docs): */
  23. #define DELAY_TIMER 1   /* Use timer.device for SCL-delay  */
  24. #define DELAY_LOOP  2   /* Use for/next-loop for SCL-delay */
  25.  
  26. /* Allocation Errors */
  27. /* (as returned by AllocI2C, BringBackI2C, or found in the middle high */
  28. /* byte of the error codes from V39's SendI2C/ReceiveI2C) */
  29. enum {
  30.     I2C_OK=0,               /* Hardware allocated successfully */
  31.     I2C_PORT_BUSY,          /* \_Allocation is actually done in two steps: */
  32.     I2C_BITS_BUSY,          /* / port & bits, and each step may fail */
  33.     I2C_NO_MISC_RESOURCE,   /* Shouldn't occur, something's very wrong */
  34.     I2C_ERROR_PORT,         /* Failed to create a message port */
  35.     I2C_ACTIVE,             /* Some other I2C client has pushed us out */
  36.     I2C_NO_TIMER            /* Failed to open the timer.device */
  37.     };
  38.  
  39. /* I/O Errors */
  40. /* (as found in the middle low byte of the error codes from V39's */
  41. /* SendI2C/ReceiveI2C) */
  42. enum {
  43.     /*I2C_OK=0,*/       /* Last send/receive was OK */
  44.     I2C_REJECT=1,       /* Data not acknowledged (i.e. unwanted) */
  45.     I2C_NO_REPLY,       /* Chip address apparently invalid */
  46.     SDA_TRASHED,        /* SDA line randomly trashed. Timing problem? */
  47.     SDA_LO,             /* SDA always LO \_wrong interface attached, */
  48.     SDA_HI,             /* SDA always HI / or none at all? */
  49.     SCL_TIMEOUT,        /* \_Might make sense for interfaces that can */
  50.     SCL_HI,             /* / read the clock line, but currently none can. */
  51.     I2C_HARDW_BUSY      /* Hardware allocation failed */
  52.     };
  53.  
  54. /* ======================================================================== */
  55. /* === I2C_Base =========================================================== */
  56. /* ======================================================================== */
  57. /*
  58.  * Starting with V40, i2c.library exposes some statistics counters, and a
  59.  * hint what kind of hardware implementation you are dealing with, in its
  60.  * base structure. These data weren't present in any of the previous
  61.  * releases, so check the lib version before you try to read them.
  62.  */
  63.  
  64. /* This structure is READ ONLY, and only present in V40 or later! */
  65. struct I2C_Base
  66.     {
  67.     struct Library LibNode;
  68.     ULONG SendCalls;        /* calls to SendI2C */
  69.     ULONG SendBytes;        /* bytes actually sent */
  70.     ULONG RecvCalls;        /* calls to ReceiveI2C */
  71.     ULONG RecvBytes;        /* bytes actually received */
  72.     ULONG Lost;             /* calls rejected due to resource conflicts */
  73.     ULONG Unheard;          /* calls to addresses that didn't reply */
  74.     ULONG Overflows;        /* times a chip rejected some or all of our data */
  75.     ULONG Errors;           /* errors caused by hardware/timing problems */
  76.     UBYTE HwType;           /* implementation: 0=par, 1=ser, 2=disk, 3=card */
  77.  
  78.     /* The data beyond this point is private and is different between
  79.      * most of the various i2c.library implementations anyway.
  80.      */
  81.     };
  82.  
  83. #endif  /* LIBRARIES_I2C_H */
  84.